//
//  RBMyCoinVC.m
//  zhongzhenglu
//
//  Created by XL on 2022/8/3.
//

#import "RBMyCoinVC.h"
#import "UIView+RBAdd.h"
#import "UIScrollView+RBAdd.h"
#import <Masonry.h>
#import "RBThemeConfig.h"
#import <UIColor+YYAdd.h>
#import <UIView+YYAdd.h>
#import "RanTool.h"
#import "RBPager.h"
#import <UINavigationController+FDFullscreenPopGesture.h>
#import "UIViewController+RBAdd.h"
#import "RBNavigationBar.h"
#import "RBMyWalletDetailVC.h"
#import "RBMyCoinChargeVC.h"

@interface RBMyCoinVC ()

@property(nonatomic, strong)RBNavigationBar *navigationBar;
@property(nonatomic, strong)UIScrollView *scrollView;
@property(nonatomic, strong)UIView *topView;
@property(nonatomic, strong)UILabel *signBtn;
@property(nonatomic, strong)UILabel *coinL;
@property(nonatomic, strong)UILabel *noteL;

@end

@implementation RBMyCoinVC

#pragma mark - Lifecycle

- (void)viewDidLoad
{
    [super viewDidLoad];
    [self setup];
}

#pragma mark - Private

- (void)setup
{
    self.statusBarStyle = UIStatusBarStyleLightContent;
    self.fd_prefersNavigationBarHidden = YES;
    self.view.backgroundColor = [RBThemeConfig bgGrayColor];
    UIImageView *topBgImgView = ({
        UIImageView *view = UIImageView.new;
        view.image = [UIImage imageNamed:@"mine_bg"];
        view.contentMode = UIViewContentModeScaleAspectFill;
        view;
    });
    [self.view addSubview:topBgImgView];
    [topBgImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.mas_equalTo(0);
        make.height.mas_equalTo(kRBStatusBarHeight + kRBNavigationBarHeight + Zoom(110));
    }];
    self.navigationBar.hidden = NO;
    [self.scrollView rbSetContentWidth:kRBMainScreenWidth];
    [self.scrollView addView:({
        UILabel *view = UILabel.new;
        self.coinL = view;
        view.attributedText = [RanTool attributeStringMaker:^(NSMutableArray *maker) {
            [maker addAttributeStringWithFont:[UIFont boldSystemFontOfSize:Zoom(24)] color:UIColor.whiteColor string:@"0"];
            [maker addAttributeStringWithFont:[UIFont boldSystemFontOfSize:Zoom(13)] color:UIColor.whiteColor string:@"枚"];
        }];
        view;
    }) withHeight:CGFLOAT_MIN width:CGFLOAT_MIN top:Zoom(12) bottom:0 left:CGFLOAT_MIN right:CGFLOAT_MIN centerX:YES];
    [self.scrollView addView:({
        UILabel *view = [RanTool labelWithFontSize:Zoom(14) weight:1 color:UIColor.whiteColor align:0 text:@"我的虚拟币"];
        view.alpha = 0.6;
        view;
    }) withHeight:CGFLOAT_MIN width:CGFLOAT_MIN top:Zoom(11) bottom:0 left:CGFLOAT_MIN right:CGFLOAT_MIN centerX:YES];
    [self.scrollView addView:self.topView withHeight:CGFLOAT_MIN width:self.topView.width top:Zoom(24) bottom:0 left:CGFLOAT_MIN right:CGFLOAT_MIN centerX:YES];
    [self.scrollView addView:({
        UIView *view = UIView.new;
        view.backgroundColor = UIColor.whiteColor;
        [view rbSetCornerRadius:Zoom(8)];
        
        UILabel *titleL = [RanTool labelWithFontSize:Zoom(16) weight:1 color:[RBThemeConfig textBlackColor] align:0 text:@"使用规则"];
        [view view_addView:titleL withHeight:CGFLOAT_MIN width:CGFLOAT_MIN top:Zoom(27) bottom:CGFLOAT_MIN left:Zoom(15) right:CGFLOAT_MIN centerX:0];
        [view view_addView:self.noteL withHeight:CGFLOAT_MIN width:CGFLOAT_MIN top:Zoom(20) bottom:Zoom(30) left:Zoom(15) right:Zoom(15) centerX:0];
        
        view;
    }) withHeight:CGFLOAT_MIN width:Zoom(343) top:Zoom(10) bottom:0 left:CGFLOAT_MIN right:CGFLOAT_MIN centerX:YES];
}

#pragma mark - Network

#pragma mark - Event

- (void)signBtnTapped
{
    
}

- (void)detailBtnTapped
{
    RBMyWalletDetailVC *vc = RBMyWalletDetailVC.new;
    vc.type = 1;
    [self.navigationController pushViewController:vc animated:YES];
}

- (void)chargeBtnTapped
{
    RBMyCoinChargeVC *vc  = RBMyCoinChargeVC.new;
    [self.navigationController pushViewController:vc animated:YES];
}


#pragma mark - Setter

#pragma mark - Getter

- (UIScrollView *)scrollView
{
    if (!_scrollView)
    {
        self.scrollView = ({
            UIScrollView *view = UIScrollView.new;
            [self.view addSubview:view];
            [view mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.right.bottom.mas_equalTo(0);
                make.top.mas_equalTo(self.navigationBar.mas_bottom);
            }];
            view;
        });
    }
    return _scrollView;
}

- (UILabel *)noteL
{
    if (!_noteL)
    {
        self.noteL = ({
            NSString *text = @"1、由于网络原因，提现申请会出现延时处理现象，请在24小时内注意查收\n2、请及时关注零钱，查询是否充值成功\n3、请及时关注余额记录中是否有余额转入\n4、可通过余额明细，查看交易详情\n5、如果充值过程中涉及任何手续费用都由用户承担";
            UILabel *textL = UILabel.new;
            textL.numberOfLines = 0;
            textL.attributedText = [RanTool attributeStringMaker:^(NSMutableArray *maker) {
                [maker addAttributeStringWithFont:[UIFont systemFontOfSize:Zoom(12)] color:[UIColor colorWithHexString:@"#9EA3A9"] string:text lineSpacing:Zoom(7)];
            }];
            textL;
        });
    }
    return _noteL;
}

- (RBNavigationBar *)navigationBar
{
    if (!_navigationBar)
    {
        self.navigationBar = ({
            RBNavigationBar *view = RBNavigationBar.new;
            view.needGradientView = NO;
            view.bgColor = UIColor.clearColor;
            
            [view.naviBar addBackBtn];
            
            UILabel *titleL = [RanTool labelWithFontSize:16 weight:1 color:UIColor.whiteColor align:1 text:@"虚拟币"];
            [view.naviBar addSubview:titleL];
            [titleL mas_makeConstraints:^(MASConstraintMaker *make) {
                make.center.mas_equalTo(0);
            }];
            
            [self.view addSubview:view];
            [view mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.right.top.mas_equalTo(0);
                make.height.mas_equalTo(kRBStatusBarHeight + kRBNavigationBarHeight);
            }];
            view;
        });
    }
    return _navigationBar;
}

- (UIView *)topView
{
    if (!_topView)
    {
        self.topView = ({
            UIView *view = UIView.new;
            view.width = Zoom(343);
            [view rbSetCornerRadius:Zoom(8)];
            view.backgroundColor = UIColor.whiteColor;
            
//            UIView *topView = UIView.new;
//            [view addSubview:topView];
//            [topView mas_makeConstraints:^(MASConstraintMaker *make) {
//                make.height.mas_equalTo(Zoom(59));
//                make.left.mas_equalTo(Zoom(16));
//                make.right.mas_equalTo(-Zoom(16));
//                make.top.mas_equalTo(0);
//            }];
            
//            UIImageView *coinImgView = UIImageView.new;
//            coinImgView.image = [UIImage imageNamed:@"signGold"];
//            [topView addSubview:coinImgView];
//            [coinImgView mas_makeConstraints:^(MASConstraintMaker *make) {
//                make.left.centerY.mas_equalTo(0);
//                make.width.height.mas_equalTo(Zoom(20));
//            }];
//
//            UILabel *coinL = [RanTool labelWithFontSize:Zoom(16) weight:1 color:[RBThemeConfig textBlackColor] align:0 text:@"签到获得虚拟币"];
//            [topView addSubview:coinL];
//            [coinL mas_makeConstraints:^(MASConstraintMaker *make) {
//                make.left.mas_equalTo(coinImgView.mas_right).offset(Zoom(8));
//                make.centerY.mas_equalTo(0);
//            }];
//
//            UILabel *signL = [RanTool labelWithFontSize:Zoom(13) weight:1 color:UIColor.whiteColor align:1 text:@"签到"];
//            signL.backgroundColor = [UIColor colorWithHexString:@"#F25B50"];
//            [signL rbSetCornerRadius:Zoom(13)];
//            [signL rbAddTapGesWithTarget:self action:@selector(signBtnTapped)];
//            self.signBtn = signL;
//            [topView addSubview:signL];
//            [signL mas_makeConstraints:^(MASConstraintMaker *make) {
//                make.right.centerY.mas_equalTo(0);
//                make.width.mas_equalTo(Zoom(63));
//                make.height.mas_equalTo(Zoom(26));
//            }];
            
//            UIView *lineView = UIView.new;
//            lineView.backgroundColor = [RBThemeConfig lineGrayColor];
//            [view addSubview:lineView];
//            [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
//                make.left.right.mas_equalTo(topView);
//                make.top.mas_equalTo(topView.mas_bottom);
//                make.height.mas_equalTo(1);
//            }];
            
            UIView *bottomView = UIView.new;
            [view addSubview:bottomView];
            [bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
                make.height.mas_equalTo(Zoom(54));
//                make.top.mas_equalTo(lineView.mas_bottom);
                make.bottom.mas_equalTo(0);
//                make.left.right.mas_equalTo(topView);
                make.left.mas_equalTo(Zoom(16));
                make.right.mas_equalTo(-Zoom(16));
                make.top.mas_equalTo(0);
            }];
            
            UIView *sepView = UIView.new;
            sepView.backgroundColor = [RBThemeConfig lineGrayColor];
            [bottomView addSubview:sepView];
            [sepView mas_makeConstraints:^(MASConstraintMaker *make) {
                make.width.mas_equalTo(1);
                make.height.mas_equalTo(Zoom(35));
                make.center.mas_equalTo(0);
            }];
            
            UILabel *detailL = [RanTool labelWithFontSize:Zoom(15) weight:1 color:[RBThemeConfig textBlackColor] align:1 text:@"账户明细"];
            [detailL rbAddTapGesWithTarget:self action:@selector(detailBtnTapped)];
            [bottomView addSubview:detailL];
            [detailL mas_makeConstraints:^(MASConstraintMaker *make) {
                make.top.bottom.left.mas_equalTo(0);
                make.right.mas_equalTo(sepView.mas_left);
            }];
            
            UILabel *chargeL = [RanTool labelWithFontSize:Zoom(15) weight:1 color:[RBThemeConfig textBlackColor] align:1 text:@"点击充值"];
            [chargeL rbAddTapGesWithTarget:self action:@selector(chargeBtnTapped)];
            [bottomView addSubview:chargeL];
            [chargeL mas_makeConstraints:^(MASConstraintMaker *make) {
                make.top.bottom.right.mas_equalTo(0);
                make.left.mas_equalTo(sepView.mas_right);
            }];
            
            view;
        });
    }
    return _topView;
}

@end
